<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org"
	xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
	<div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="search-form" autocomplete="off">
					<div class="select-list">
						<ul>
							<li>名称 ：<input type="text" name="name" />
							</li>
							<li>类型 ：<input type="text" name="dialect" />
							</li>
							<li>主机 ：<input type="text" name="host" />
							</li>
							<li>登陆名 ：<input type="text" name="username" />
							</li>

							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>

			<div class="btn-group-sm hidden-xs" id="toolbar" role="group">
				<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="quartz:wisDataSource:add"> 
					<i class="fa fa-plus"></i> 添加
				</a> 
				<a class="btn btn-primary btn-edit " onclick="importExcel();" shiro:hasPermission="quartz:wisDataSource:add"> 
					<i class="fa fa-file-excel-o"></i>导入
				</a> 
				<a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()" shiro:hasPermission="quartz:wisDataSource:edit"> 
					<i class="fa fa-edit"></i> 修改
				</a> 
				<a class="btn btn-primary btn-edit " onclick="$.table.exportExcel('search-form')" shiro:hasPermission="quartz:wisDataSource:add"> 
					<i class="fa fa-file-o"></i>导出
				</a> 
				<a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="quartz:wisDataSource:remove"> 
					<i class="fa fa-remove"></i> 删除
				</a>
			</div>

			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>

		</div>
	</div>
	<div th:include="include :: footer"></div>
	<script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('quartz:wisDataSource:edit')}]];
        var removeFlag = [[${@permission.hasPermi('quartz:wisDataSource:remove')}]];
        var prefix = ctx + "quartz/wisDataSource";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "数据源",
                columns: [{
		            checkbox: true
		        },
				{
					field : 'id', 
					title : '主键' ,
					visible : false
				},
				{
					field : 'name', 
					title : '名称' 
				},
				{
					field : 'dialect', 
					title : '类型' 
				},
				{
					field : 'host', 
					title : '主机' 
				},
				{
					field : 'username', 
					title : '登陆名' 
				},
				{
					field : 'password', 
					title : '密码' 
				},
				{
					field : 'port', 
					title : '端口号' 
				},

				{
					field : 'dbName', 
					title : '数据库' 
				},
				{
					field : 'createBy', 
					title : '创建人' 
				},
					{
					field : 'createTime', 
					title : '创建时间' 
				},
					{
					field : 'updateBy', 
					title : '修改人' 
				},
					{
					field : 'updateTime', 
					title : '修改时间' 
				},
					{
					field : 'state', 
					title : '状态' ,
					 formatter: function(value, row, index) {
		            	var result = '禁用';
		            	if(value == 1) {
		            		result = '可用' ;
		            	}
						return result ;
		            }
				},
			        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
						return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });
        
        function importExcel() {
        	$.modal.open('数据源导入', prefix + "/importExcel", 800, 320);
        }
        
    </script>
</body>
</html>